Dynamic Traceability using DXL

All,

I wrote a code to generate traceability.
Example:
The code will traverse through the link from one module to another module and then it will finially reach target.... If the target is reached it will put "X" in the object and come to the next Object and bla bla bla.....

Below is the code it perfectly works in a smaill module. But when I ran the code in a big module contains 1200 Objects.. It's hang & going to not responding mode ;-(
I attached code here.. Looking for your help....
//************ Code starts here *****************//

pragma runLim, 0
Module M = current
string sourceModulefullName = fullName (M)
refresh M
Object tracedObject

int countRecursive = 0
int srcAbsno

string srcModName = "BNSF PO1"
string attrName = srcModName

string targetFullName1
string targetFullName2
string TrgModName1
string TrgModName2
Link link1
Link link2
bool matchedflag=false
GoToNextObjectFlag = false

bool recursiveSearch(string, Object)

Filter f = hasLinks(linkFilterOutgoing, "*")
set(M, f)
filtering on

AttrDef adRec
if (exists attribute attrName)
{
adRec = find(M, attrName)
delete(adRec)
}
adRec = create object type "Text" attribute srcModName

void traceObject()
{
Module traceModule = edit (sourceModulefullName,false)
ack "inside"
tracedObject
tracedObject.attrName = "X"
matchedflag = true
}

bool recursiveSearch(string targetFullName2, Object recurObj)
{

//Module t2 = read(targetFullName2, false)
//recurObj = target(link3)
countRecursive = countRecursive+1

//Filter f = hasLinks(linkFilterOutgoing, "*")
//set(t2, f)
//filtering on
string TrgModName3
string targetFullName3
Link link3

for link3 in recurObj -> "*" do
{
if (matchedflag == false && GoToNextObjectFlag == false)
{
TrgModName3 = target (link3)

print "3. Target Module Name1: " TrgModName3 "\n"

targetFullName3 = fullName target (link3)
if(cistrcmp(srcModName,TrgModName3) == 0)
{
traceObject()
matchedflag = true
break
}
else
{
if (countRecursive >12)
{
GoToNextObjectFlag = true
}
else
{
Module t3 = read(targetFullName3,true)
Object nObj = target(link3)
string targetObject3 = nObj."Object Text"
print "3. Target Object3: " targetObject3 "\n"
flag = recursiveSearch(targetFullName3,nObj)
if (flag == true)
{
break
}
}
}
}
}
return matchedflag
}

for tracedObject in M do
{
bool returnedFlag = false
tracedObject
countRecursive = 0
for link1 in tracedObject -> "*" do
{
countRecursive = 0

if (returnedFlag == false)
{
TrgModName1 = target (link1)

print "1. Target Module Name1: " TrgModName1 "\n"

targetFullName1 = fullName target (link1)
if(cistrcmp(srcModName,TrgModName1) == 0)
{
traceObject()
matchedflag = true
break

}
else
{
Module t1 = read(targetFullName1, false)
current = t1
Filter f = hasLinks(linkFilterOutgoing, "*")
set(t1, f)
filtering on
Object o = target(link1)
string targetObject1 = o."Object Text"
print "1. Target Object1: " targetObject1 "\n"

for link2 in o -> "*" do
{
if (matchedflag == false)
{
TrgModName2 = target (link2)

print "2. Target Module Name1: " TrgModName2 "\n"
targetFullName2 = fullName target (link2)
if(cistrcmp(srcModName,TrgModName2) == 0)
{
traceObject()
matchedflag = true
break
}
else
{
Module t2 = read(targetFullName2, false)
Object o = target(link2)
string targetObject2 = o."Object Text"
print "2. Target Object2: " targetObject2 "\n"
print "Before Calling Recursive Method for the first time.........." "\n"

returnedFlag = recursiveSearch(targetFullName2, o)
if (returnedFlag ==true)
{
break
}

}
}
}//for
}//else

}//if returned....
else
{
break
}

}
matchedflag = false
GoToNextObjectFlag = false
}
//save M
infoBox ("Traceability Column" srcModName "has been generated successfully")

//*************** Code's end here *********************//
SystemAdmin - Sun Oct 11 06:58:39 EDT 2009

Re: Dynamic Traceability using DXL
SystemAdmin - Wed Oct 14 12:55:12 EDT 2009

Can someone help me? I would appreciate a lot. Thanks for your help in Advance..............

Regards,
Muruga

Re: Dynamic Traceability using DXL
llandale - Thu Oct 15 12:23:38 EDT 2009

if you surround your code with "{ code }", without the spaces, your posted code will have indendation and be MUCH easier to read:

if (something)
{  1
   23
}
else
{  12
   45
}

 


I could not see an infinate loop in your recursion. However, I see that you are opening up a LOT of modules and never closing them, so I conclude that you have far too many open modules which exhausts memory and will cause thrashing. Its complicated doing something about that, but you need to keep track of you 'read' target modules, and close them often.

Your print statements may be bogging you down also. Getting all that Object Text might also causes excessive string table wasted space; consider dropping it in a Buffer instead.: buf = o."Object Text"; print tempStringOf(buf).

As for your code. Yuuuuck. Anyway, you can probably save a lot of time by defining a global Skip list, KEY is 'object' target object handle, and DATA is 'bool' whether or not that object 'traces'. Inside your loop when you find a target object in the Skip list, you can determine if its traced by looking in the Skip. If not you do your code, and insert it in the skip list along with its result at the end.

Seems to me your 'link2' loop is not needed, as I think that's basically the same as inside your recursiveSearch function.

I think your recursiveSearch() function wants to stop at depth 12. Right now its stopping at the 12 object from the source object, which means it won't look at the 13th link, even when all the depth is 1. I think you should put this at the top:
...... if (countRecursive++ > 12) return(matchedflag)
and put this at the bottom of the function:
...... countRecursive--
...... return(matchedFlag)
Either that or have the 'int depth' as one of the input parameters, using 'depth+1' in the recursive call.

Don't forget that before functions that presume the 'current Module' such as 'filtering on', you should set the current module: current = M; filtering off.

 

 

 

  • Louie